package mmc.action.buff;

import java.util.HashMap;
import java.util.Map;

import mmc.action.skill.Skill;

import static org.lwjgl.input.Keyboard.CHAR_NONE;

public abstract class Buff extends Skill {
	public static Map<Buff, Float> buffs = new HashMap<Buff, Float>();
	
	public float duration = 10; 		//default 10 sec.
	
	public Buff(String name, String textureName) {
		super(name, textureName, CHAR_NONE);
	}
	
	
	public static void checkBuffs(float dt){
		if(buffs.size() > 0){
			Map<Buff, Float> cc_copy = new HashMap<Buff, Float>();
			cc_copy.putAll(buffs);
			
			synchronized (cc_copy) {
				for(Map.Entry<Buff, Float> entry : cc_copy.entrySet()){
					float help = entry.getValue()-dt;
					
					if(help < 0){
						buffs.remove(entry.getKey());
					}
					else
						buffs.put(entry.getKey(), help);			
				}
			}
		}
	}
}
